package de.szut.sudoku.gui.menu;

import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.io.IOException;

import javax.swing.JRadioButtonMenuItem;

import de.szut.sudoku.gui.MainFrame;

/**
 * Listener for the languages
 * 
 * @author dqi12huisinga
 * 
 */
public class LanguageListener implements ItemListener {

	/**
	 * Method called when clicked
	 */
	@Override
	public void itemStateChanged(ItemEvent arg0) {
		// Sets the current language
		MainFrame
				.getInstance()
				.getlContainer()
				.setCurrentLanguage(
						((JRadioButtonMenuItem) arg0.getSource()).getText());
		// Translates the components
		try {
			MainFrame.getInstance().getlContainer().translate();
		} catch (IOException e) {
			System.exit(0);
		}
	}
}
